/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entityprojet;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author T.Ron
 */
@Entity
@Table(name = "PERIODE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Periode.findAll", query = "SELECT p FROM Periode p"),
    @NamedQuery(name = "Periode.findByNumexo", query = "SELECT p FROM Periode p WHERE p.periodePK.numexo = :numexo"),
    @NamedQuery(name = "Periode.findByMois", query = "SELECT p FROM Periode p WHERE p.periodePK.mois = :mois"),
    @NamedQuery(name = "Periode.findByIntituleMois", query = "SELECT p FROM Periode p WHERE p.intituleMois = :intituleMois")})
public class Periode implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PeriodePK periodePK;
    @Column(name = "INTITULE_MOIS")
    private String intituleMois;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "periode")
    private Collection<Ecriturec> ecriturecCollection;
    @JoinColumn(name = "NUMEXO", referencedColumnName = "NUMEXO", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Exercicecompta exercicecompta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "periode")
    private Collection<Budgetcgpb> budgetcgpbCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "periode")
    private Collection<Budgetpb> budgetpbCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "periode")
    private Collection<Joperiode> joperiodeCollection;

    public Periode() {
    }

    public Periode(PeriodePK periodePK) {
        this.periodePK = periodePK;
    }

    public Periode(int numexo, int mois) {
        this.periodePK = new PeriodePK(numexo, mois);
    }

    public PeriodePK getPeriodePK() {
        return periodePK;
    }

    public void setPeriodePK(PeriodePK periodePK) {
        this.periodePK = periodePK;
    }

    public String getIntituleMois() {
        return intituleMois;
    }

    public void setIntituleMois(String intituleMois) {
        this.intituleMois = intituleMois;
    }

    @XmlTransient
    public Collection<Ecriturec> getEcriturecCollection() {
        return ecriturecCollection;
    }

    public void setEcriturecCollection(Collection<Ecriturec> ecriturecCollection) {
        this.ecriturecCollection = ecriturecCollection;
    }

    public Exercicecompta getExercicecompta() {
        return exercicecompta;
    }

    public void setExercicecompta(Exercicecompta exercicecompta) {
        this.exercicecompta = exercicecompta;
    }

    @XmlTransient
    public Collection<Budgetcgpb> getBudgetcgpbCollection() {
        return budgetcgpbCollection;
    }

    public void setBudgetcgpbCollection(Collection<Budgetcgpb> budgetcgpbCollection) {
        this.budgetcgpbCollection = budgetcgpbCollection;
    }

    @XmlTransient
    public Collection<Budgetpb> getBudgetpbCollection() {
        return budgetpbCollection;
    }

    public void setBudgetpbCollection(Collection<Budgetpb> budgetpbCollection) {
        this.budgetpbCollection = budgetpbCollection;
    }

    @XmlTransient
    public Collection<Joperiode> getJoperiodeCollection() {
        return joperiodeCollection;
    }

    public void setJoperiodeCollection(Collection<Joperiode> joperiodeCollection) {
        this.joperiodeCollection = joperiodeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (periodePK != null ? periodePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Periode)) {
            return false;
        }
        Periode other = (Periode) object;
        if ((this.periodePK == null && other.periodePK != null) || (this.periodePK != null && !this.periodePK.equals(other.periodePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entityprojet.Periode[ periodePK=" + periodePK + " ]";
    }
    
}
